import request from '@/config/axios'

// ERP 随货同行单 VO
export interface SupplierSendOrderVO {
  id: number // 编号
  outOrderId: string // 随货同行单编号
  integrateId: string // 一级库整合单编号
  purchaseOrderId: string // 采购单编号-提交供应商采购单编号
  supplierId: number // 供应商编号
  sendTime: Date // 发货时间
  totalPrice: number // 合计价格，单位：元
  remark: string // 备注
  status: number // 状态
  processInstanceId: string // 流程实例的编号
  supplierSendOrderItems:any
}

// ERP 随货同行单 API
export const SupplierSendOrderApi = {
  // 查询ERP 随货同行单分页
  getSupplierSendOrderPage: async (params: any) => {
    return await request.get({ url: `/erp/supplier-send-order/page`, params })
  },

  // 查询ERP 随货同行单详情
  getSupplierSendOrder: async (id: number) => {
    return await request.get({ url: `/erp/supplier-send-order/get?id=` + id })
  },

  // 新增ERP 随货同行单
  createSupplierSendOrder: async (data: SupplierSendOrderVO) => {
    return await request.post({ url: `/erp/supplier-send-order/create`, data })
  },

  // 修改ERP 随货同行单
  updateSupplierSendOrder: async (data: SupplierSendOrderVO) => {
    return await request.put({ url: `/erp/supplier-send-order/update`, data })
  },

    // 打印 随货同行单
    printSupplierSendOrder: async (data: SupplierSendOrderVO) => {
      return await request.put({ url: `/erp/supplier-send-order/print`, data })
    },

  // 删除ERP 随货同行单
  deleteSupplierSendOrder: async (id: number) => {
    return await request.delete({ url: `/erp/supplier-send-order/delete?id=` + id })
  },

  // 导出ERP 随货同行单 Excel
  exportSupplierSendOrder: async (params) => {
    return await request.download({ url: `/erp/supplier-send-order/export-excel`, params })
  },

  // 根据入库单编号获取随货同行单列表
  getSupplierSendOrderListByInId: async (inId) => {
    return await request.get({ url: `/erp/supplier-send-order/list-by-in-id?inId=` + inId })
  },

  getItemListByOutOrderId: async (outOrderId) => {
    return await request.get({ url: `/erp/supplier-send-order/supplier-send-order-item/getItemListByOutOrderId?outOrderId=` + outOrderId })
  },


// ==================== 子表（ERP 随货同行单项） ====================

  // 获得ERP 随货同行单项列表
  getSupplierSendOrderItemListByOutOrderId: async (outOrderId) => {
    return await request.get({ url: `/erp/supplier-send-order/supplier-send-order-item/list-by-out-order-id?outOrderId=` + outOrderId })
  },

   // 根据订单号获得随货同行单项列表
   getSupplierSendOrderItemListByPurchaseOrderId: async (purchaseOrderId) => {
    return await request.get({ url: `/erp/supplier-send-order/getSupplierSendOrderItemListByPurchaseOrderId?purchaseOrderId=` + purchaseOrderId })
  },

     // 根据订单号获得未打印随货同行单项列表
     getSupplierSendOrderItemPrintListByPurchaseOrderId: async (purchaseOrderId) => {
      return await request.get({ url: `/erp/supplier-send-order/getSupplierSendOrderItemPrintListByPurchaseOrderId?purchaseOrderId=` + purchaseOrderId })
    },
   // 获得ERP 随货同行单项分页
   getSupplierSendOrderItemPage: async (params) => {
    return await request.get({ url: `/erp/supplier-send-order/supplier-send-order-item/page`, params })
  },
  // 新增ERP 随货同行单项
  createSupplierSendOrderItem: async (data) => {
    return await request.post({ url: `/erp/supplier-send-order/supplier-send-order-item/create`, data })
  },

  // 修改ERP 随货同行单项
  updateSupplierSendOrderItem: async (data) => {
    return await request.put({ url: `/erp/supplier-send-order/supplier-send-order-item/update`, data })
  },

  // 删除ERP 随货同行单项
  deleteSupplierSendOrderItem: async (id: number) => {
    return await request.delete({ url: `/erp/supplier-send-order/supplier-send-order-item/delete?id=` + id })
  },

  // 获得ERP 随货同行单项
  getSupplierSendOrderItem: async (id: number) => {
    return await request.get({ url: `/erp/supplier-send-order/supplier-send-order-item/get?id=` + id })
  },

  //根据订单号数组获得随货同行单项列表
  getSupplierSendOrderItemListByPurchaseOrderIds: async (purchaseOrderIds) => {
    return await request.get({ url: `/erp/supplier-send-order/list-by-out-order-ids?purchaseOrderIds=` + purchaseOrderIds})
  },

  
}
